/*********************************************************************
	filename:	DaterMessageQueue.h
	created:	11/5/2012
	author:		4Ys
	
	purpose:	Defines message queue class.
*********************************************************************/
#ifndef _DaterMessageQueue_h_
#define _DaterMessageQueue_h_

#include "DaterSingleton.h"
#include <queue>
#include <string>

namespace Dater
{
	/*!
	\brief
		An entity class contains 21 year calendars front and back.
	*/
	class MessageQueue
	{
	public:
		/*!
		\brief
			Constructor for CalendarData class
		*/
		MessageQueue();

		/*!
		\brief
			a function to push the string into the queue.
			
		\param message
			the string to push.
		*/
		void push(std::string message);
		
		/*!
		\brief
			a function to get the front element.
		*/
		std::string front();

		/*!
		\brief
			a function to pop the first element.
		*/
		void pop();

		/*!
		\brief
			a function to push into the queue.
		*/
		void pushMessageToBuffer(std::string message);
		/*!
		\brief
			a function to get the front element.
		*/

		void pushBufferToQueue();
		
		/*!
		\brief
			a function to determine if the queue is locked.
		*/

		bool isLocked();

		/*!
		\brief
			a function to lock the queue.
		*/
		void lock();

		/*!
		\brief
			a function to unlock the queue.
		*/
		void unLock();

		unsigned int size();

	private:
		bool _locked;

		std::queue<std::string> _messageQueue;

		std::queue<std::string> _messageBuffer;
	};

	class RecvMessageQueue : public MessageQueue, public Singleton<RecvMessageQueue>
	{
	public:
		RecvMessageQueue() : MessageQueue(){}
	};

	class SendMessageQueue : public MessageQueue, public Singleton<SendMessageQueue>
	{
	public:
		SendMessageQueue() : MessageQueue(){}
	};
}

#endif